import Vue from "vue";
import VueRouter from "vue-router";
import Login from "../views/Login.vue";
import Layout from "../layout/Index.vue";
import Station from "../views/Station.vue";
import Train from "../views/Train.vue";
import User from "../views/User.vue";
import Order from "../views/Order.vue";
import Pass from "../views/Pass.vue";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    redirect: "/login",
  },
  {
    path: "/login",
    name: "Login",
    component: Login,
  },
  {
    path: "/layout",
    name: "Layout",
    component: Layout,
    redirect: "/station",
    children: [
      {
        path: "/station",
        component: Station,
      },
      {
        path: "/train",
        component: Train,
      },
      {
        path: "/user",
        component: User,
      },
      {
        path: "/order",
        component: Order,
      },
      {
        path: "/pass",
        component: Pass,
      },
    ],
  },
];

const router = new VueRouter({
  routes,
});

// router.beforeEach((to, from, next) => {
//   if (localStorage.getItem("jobAdminUserId")) {
//     next();
//   } else {
//     next({
//       path: '/login'
//     });
//   }
// })

export default router;
